<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html>

    <head>

        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <title>Lei's Blog | Posts</title>

        <link href="/static/css/bootstrap.min.css" rel="stylesheet">
        <link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet">
        <link href="/static/css/animate.css" rel="stylesheet">
        <link href="/static/css/style.css" rel="stylesheet">

        <link href="/static/css/plugins/footable/footable.core.css" rel="stylesheet"> 
        <link href="/static/js/plugins/summernote/summernote.css" rel="stylesheet"> 
        <link href="/static/css/plugins/summernote/summernote-bs3.css" rel="stylesheet"> 
        <!--<link href="/static/js/plugins/umeditor/themes/default/css/umeditor.min.css" rel="stylesheet">--> 

        <script data-main="/static/js/admin-frame.js" src="/static/js/require.min.js"></script>
    </head>

    <body class="white-bg">

        <i id="scriptTag">/static/js/admin/admin-post-config.js</i>
        <div class="panel panel-primary">
            <div class="panel-heading">
                博文管理
            </div>
            <div class="panel-body">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a data-toggle="tab" href="#post-add">
                                博文创建
                            </a>
                        </li>
                        <li>
                            <a data-toggle="tab" href="#post-list">博文列表</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="post-add" class="tab-pane active">
                            <div class="panel-body">
                                <div class="row">
                                    <div class="col-lg-10">
                                        <form class="form-horizontal" id="post-config-form">
                                            <div class="form-group">
                                                <label class="col-lg-2 control-label">标题</label>
                                                <div class="col-lg-10">
                                                    <input type="text" name="post-title" id="post-title" class="form-control">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-lg-2 control-label">分类</label>
                                                <div class="col-lg-10">
                                                    <select id="post-cat" name="post-cat" class="form-control m-b">
                                                        <option value="" selected>请选择</option>
                                                        <?php foreach ($cats as $item): ?>
                                                            <option value="<?php echo $item['cat_id']; ?>"><?php echo $item['cat_name']; ?></option>
                                                        <?php endforeach; ?>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-lg-2 control-label">标签</label>
                                                <div class="col-lg-10">
                                                    <?php foreach ($tags as $item): ?>
                                                        <a href="#" class="tag-item btn" 
                                                           data-id="<?php echo $item['tag_id']; ?>">
                                                               <?php echo $item['tag_name']; ?>
                                                        </a>
                                                    <?php endforeach; ?>
                                                </div>
                                            </div>
<!--                                            <div class="form-group">
                                                <label class="col-lg-2 control-label">内容</label>
                                                <div class="col-lg-10">
                                                    <script id="ueditor-container" name="content" type="text/plain" style="min-height:400px;">
                                                    </script>
                                                </div>
                                            </div>-->
                                            <div class="form-group">
                                                <label class="col-lg-2 control-label">内容</label>
                                                <div class="col-lg-10">
                                                    <div id="summernote"></div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <div class="col-lg-offset-2 col-lg-10">
                                                    <button id="post-add-btn" class="btn btn-white" type="button"><i class="fa fa-check text-navy"></i></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="post-list" class="tab-pane">
                            <div class="panel-body">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                        <button type="button" class="btn btn-primary"><i class="fa fa-search"></i></button>
                                    </span>
                                    <input type="text" class="form-control" id="filter" placeholder="">
                                </div>
                                <table id="post-list-table" class="footable table table-stripped toggle-arrow-tiny" data-page-size="8" data-filter='#filter'>
                                    <thead>
                                        <tr>
                                            <th>序号</th>
                                            <th>标题</th>
                                            <th>创建时间</th>
                                            <th>点击数</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php foreach ($post as $item): ?>
                                            <tr>
                                                <td><?php echo $item['post_id']; ?></td>
                                                <td><?php echo $item['post_title']; ?></td>
                                                <td><?php echo date('Y-m-d H:m:s', $item['post_create_time']); ?></td>
                                                <td><?php echo $item['post_views']; ?></td>
                                                <td>
                                                    <a href="/admin/edit_post/<?php echo $item['post_id']; ?>" class="btn btn-circle btn-primary" title="修改"><i class="fa fa-edit"></i></a>
                                                    <button data-postid = "<?php echo $item['post_id']; ?>" class="del-post-btn btn btn-circle btn-success" title="删除"><i class="fa fa-times"></i></button>
                                                </td>
                                            </tr>
                                        <?php endforeach; ?>
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                            <td colspan="5">
                                                <ul class="pagination pull-right"></ul>
                                            </td>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>



